<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Feedback;
use Illuminate\Http\Request;
use Validator;

class FeedbackController extends Controller {
	//插件下载
	public function plugDowload() {
		return $this->respond('get_ok', ['path' => 'image/chrome_server_plugin.crx']);

	}
	//官网提交用户留言内容
	public function add(Request $request) {
		$validator = Validator::make($request->all(), Feedback::$rules, Feedback::$message);
		if ($validator->fails()) {
			return response()->json(['code' => 500, 'msg' => $validator->errors()->first()]);
		}
		$m = new Feedback();
		$m->name = $request->input('name');
		$m->mobile = $request->input('mobile');
		$m->msg = $request->input('msg');
		$result = $m->save();
		if ($result) {
			return $this->respond('op_ok');
		}
		return $this->respond('op_error');
	}
}
